package np13;

/**
 * A logging class for convenience :-)
 */
public class Logger {

	/**
	 * Logs a message and prints it to the console. The class name and line
	 * number of the caller will be prefixed automatically.
	 * 
	 * @param message
	 *            The message to log.
	 */
	public static void log(String message) {
		final StackTraceElement caller = Thread.currentThread().getStackTrace()[2];
		String shortClassName = caller.getClassName();
		shortClassName = shortClassName.substring(shortClassName
				.lastIndexOf(".") + 1);
		System.out.println(shortClassName + "." + caller.getMethodName() + "["
				+ caller.getLineNumber() + "]: " + message);
	}
}
